import { ItemData } from "../../../resource/info/ItemData";
import { Cache } from "../../../cache/Cache";
import { EPetLifeStyle } from "../../../../../Message/Public/EPetLifeStyle";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { Language } from "../../../../../extend/language/Language";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { LifestyleUpgradeConfig } from "../../../resource/LifestyleUpgradeConfig";
import { PetMingUtil } from "./PetMingUtil";
type int = number;
//class PetMingItemData
    
    export  class PetMingItemData extends ItemData
    {
        constructor(arg1)
        {
            super(arg1);
            this.initData();
            return;
        }

        public get isLock(): Boolean
        {
            if (itemExInfo) 
            {
                return itemExInfo.ls_lc_flg == 1;
            }
            return false;
        }

        public set isLock(arg1: Boolean)
        {
            if (itemExInfo) 
            {
                itemExInfo.ls_lc_flg = arg1 != true ? 0 : 1;
            }
            return;
        }

        public get lsExp(): int
        {
            if (itemExInfo) 
            {
                this._lsExp = itemExInfo.ls_exp;
            }
            return this._lsExp;
        }

        public get lsLevel(): int
        {
            if (itemExInfo) 
            {
                this._lsLevel = itemExInfo.ls_level;
            }
            return this._lsLevel;
        }

        public get lsIndex(): int
        {
            if (itemExInfo) 
            {
                this._lsIndex = itemExInfo.ls_index;
            }
            return this._lsIndex;
        }

        public get score(): int
        {
            if (itemExInfo) 
            {
                this._score = itemExInfo.life_s_s;
            }
            return this._score;
        }

        public get upgradeExp(): int
        {
            return this._upgradeExp;
        }

        public get isMax(): Boolean
        {
            return this._lsLevel == 10;
        }

        public get isCanUpgrade(): Boolean
        {
            return !this.isMax && this.isExpEnough;
        }

        public get isExpEnough(): Boolean
        {
            var loc1=Cache.instance.petMing.swallExp;
            return loc1 >= this.upgradeExp - this.lsExp;
        }

        public get isExpLifeStyle(): Boolean
        {
            return this.type == EPetLifeStyle._EPetLifeStyleExp;
        }

        public get isRed(): Boolean
        {
            return ItemsUtil.isRedPetLifeStyle(this);
        }

        public getAttrValue(arg1: int=-1): int
        {
            if (arg1 == -1) 
            {
                arg1 = type;
            }
            return (this.lsLevel + 1) * this._baseAttrDict[arg1];
        }

        public getNextAttrValue(arg1: int=-1): int
        {
            if (arg1 == -1) 
            {
                arg1 = type;
            }
            return (this.lsLevel + 2) * this._baseAttrDict[arg1];
        }

        public get exp(): int
        {
            return this.effect + this.lsExp;
        }

        public getAttrDesc(arg1: string="\n", arg2: Boolean=false): string
        {
            var loc2=0;
            var loc3=0;
            var loc4=0;
            var loc1="";
            if (this.isExpLifeStyle) 
            {
                loc1 = Language.getString(54756) + effect;
            }
            else 
            {
                loc4 = 0;
                while (loc4 < this._attrTypeArray.length) 
                {
                    loc2 = this._attrTypeArray[loc4];
                    if (arg2) 
                    {
                        loc3 = this.getNextAttrValue(loc2);
                    }
                    else 
                    {
                        loc3 = this.getAttrValue(loc2);
                    }
                    loc1 = loc1 + (GameDefConfig.instance.getPetLifeStyleName(loc2) + " +" + loc3);
                    if (loc4 != (this._attrTypeArray.length - 1)) 
                    {
                        loc1 = loc1 + arg1;
                    }
                    ++loc4;
                }
            }
            return loc1;
        }

        /* internal  */initData(): void
        {
            var loc2=0;
            var loc3=0;
            var loc1=LifestyleUpgradeConfig.instance.getUpgradeInfo(this.color);
            if (loc1) 
            {
                this._upgradeExp = loc1.getExpByLevel(this.lsLevel + 1);
            }
            this._attrTypeArray = [];
            this._baseAttrDict = new Map<any, any> /* flash.utils.Dictionary */();
            if (this.isRed) 
            {
                this._attrTypeArray = PetMingUtil.getAttrTypeArray(this);
                loc3 = 0;
                while (loc3 < this._attrTypeArray.length) 
                {
                    loc2 = int(this._attrTypeArray[loc3]);
                    this._baseAttrDict[loc2] = PetMingUtil.getAttrByType(loc2, this);
                    ++loc3;
                }
            }
            else 
            {
                loc2 = type;
                this._attrTypeArray.push(loc2);
                this._baseAttrDict[loc2] = PetMingUtil.getAttrByType(loc2, this);
            }
            return;
        }

        public /* var */isShowNext: Boolean=false;

        /* internal */ /* var */_lsExp: int=0;

        /* internal */ /* var */_lsLevel: int=1;

        /* internal */ /* var */_lsIndex: int=0;

        /* internal */ /* var */_upgradeExp: int=0;

        /* internal */ /* var */_score: int=0;

        /* internal */ /* var */_attrTypeArray: Array<any>;

        /* internal */ /* var */_baseAttrDict: Map<any, any> /* flash.utils.Dictionary */;
    }
